home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / T / TransSkel 3.11.sit / TransSkel v 3.11 / Core / SkelGetWindRect.c / SkelGetWindRect.c
Encoding:
C/C++ Source or Header  |  1994-02-20  |  2.0 KB  |  68 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Calculate content or structure rectangle for a window. These are
  3.  * core routines because they are called by other core routines,
  4.  * e.g., SkelGetWindowDevice() and SkelGetWindTitleHeight ().
  5.  */
  6.  
  7. # include    "TransSkel.h"
  8.  
  9. # define    kTranslate    0x4000
  10.  
  11.  
  12. /*
  13.  * Get content rectangle and convert it to global coordinates
  14.  */
  15.  
  16. pascal void
  17. SkelGetWindContentRect (WindowPtr w, Rect *rp)
  18. {
  19. GrafPtr    oldPort;
  20. Rect    content;
  21.  
  22.     GetPort (&oldPort);
  23.     SetPort (w);
  24.     *rp = w->portRect;
  25.     LocalToGlobal (&topLeft (*rp));
  26.     LocalToGlobal (&botRight (*rp));
  27.     SetPort (oldPort);
  28. }
  29.  
  30.  
  31. /*
  32.  * Get structure rectangle.  This is already in global coordinates, but the
  33.  * tricky part is that it isn't valid if the window is invisible.
  34.  *
  35.  * If window's visible, the structure region's valid, so get the bounding box.
  36.  *
  37.  * If the window's not visible, fling it out into space, make it visible, get
  38.  * the structure region bounding box, make it invisible again and restore it to
  39.  * its normal position.  Use ShowHide() for this since  it doesn't change the
  40.  * window's hiliting or position in the stacking order.  The rectangle
  41.  * calculated this way has to be moved back, too, since it's obtained when the
  42.  * window is in flung position.
  43.  *
  44.  * I have seen similar code that also saves and restored the window's userState,
  45.  * but Inside Macintosh (Toolbox Essentials, p. 4-70) explicitly states that
  46.  * the userState isn't modified when you just move a window, so I don't see the
  47.  * point.
  48.  */
  49.  
  50. pascal void
  51. SkelGetWindStructureRect (WindowPtr w, Rect *rp)
  52. {
  53. Rect    content;
  54.  
  55.     if (((WindowPeek) w)->visible)
  56.         *rp = (**(* (WindowPeek) w).strucRgn).rgnBBox;
  57.     else
  58.     {
  59.         SkelGetWindContentRect (w, &content);                /* get upper-left coords */
  60.         MoveWindow (w, kTranslate, content.top, false);        /* fling window */
  61.         ShowHide (w, true);
  62.         *rp = (**(* (WindowPeek) w).strucRgn).rgnBBox;
  63.         ShowHide (w, false);
  64.         MoveWindow (w, content.left, content.top, false);    /* unfling window */
  65.         OffsetRect (rp, content.left - kTranslate, 0);        /* unfling struct rect */
  66.     }
  67. }
  68.